﻿/*
 * Cratos Example - Data Object
 * Cratos Example Title class
 * 
 * Copyright (c) 2011 Draco
 * 
 * This file is part of Cratos.
 * 
 * Cratos is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * Cratos is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Cratos.  If not, see <http://www.gnu.org/licenses/>.
 * 
 *       .==.        .==.
 *      //'^\\      //^'\\
 *     // ^ ^\(\__/)/^ ^^\\
 *    //^ ^^ ^/6  6\ ^^ ^ \\
 *   //^ ^^ ^/( .. )\^ ^ ^ \\
 *  // ^^ ^/\| V""V|/\^ ^ ^ \\
 * //^^/\/ /  '~~'  \ \/\^ ^ \\
 *  ------------------------------------
 *  HERE BE DRAGONS
 *  
 *  Johan Dercksen - johan@draco.co.za
 */
using System;
using System.Linq;
using System.Text;
using System.Data;
using System.Collections.Generic;

using Cratos.Tools.General;
using Cratos.Tools.DataObject;

namespace Cratos.Example.DataObject
{
	/// <summary>
	/// Title Data Object class
	/// </summary>
	[DOCratos("Title")]
	[Serializable]
	[DOCratosAction(DOCratosAction.Retrieve, DOCratosActionType.StoredProcedure, true, "spTitle_Retrieve")]
	[DOCratosAction(DOCratosAction.Create, DOCratosActionType.StoredProcedure, true, "spTitle_Create")]
	[DOCratosAction(DOCratosAction.Update, DOCratosActionType.StoredProcedure, false, "spTitle_Update")]
	[DOCratosAction(DOCratosAction.Delete, DOCratosActionType.StoredProcedure, false, "spTitle_Delete")]
	public class DOTitle : DOCratos, IDOCratos
	{
		#region Class Constant declarations
		private const string DBIdColumn = "Title_ID";
		private const string DBNameColumn = "Title_Name";
		private const string DBIsActiveColumn = "Title_IsActive";
		#endregion

		#region Class Event declarations
		#endregion

		#region Class Variable declarations
		private long m_Id;
		private string m_Name;
		private bool m_IsActive;
		#endregion

		#region Class Constructors & Destructors
		/// <summary>
		/// Class Constructor
		/// </summary>
		public DOTitle()
			: base()
		{
			// Set the relevant CRUD Action indicators
			this.CanCreate = true;
			this.CanRetrieve = true;
			this.CanUpdate = true;
			this.CanDelete = true;
		}
		#endregion

		#region Class Properties
		/// <summary>
		/// Title ID
		/// </summary>]
		[DOCratosColumn("ID", "Id", DbType.Int64, DOTitle.DBIdColumn, 0, IsKey = true)]
		[DOCratosActionColumn(DOCratosAction.Retrieve, true)]
		[DOCratosActionColumn(DOCratosAction.Update, true)]
		[DOCratosActionColumn(DOCratosAction.Delete, true)]
		public long Id
		{
			get { return (this.m_Id); }
			set { this.m_Id = value; this.NotifyPropertyChanged("Id"); this.IsChanged = true; }
		}

		/// <summary>
		/// Title Name
		/// </summary>
		[DOCratosColumn("Name", "Name", DbType.String, DOTitle.DBNameColumn)]
		[DOCratosActionColumn(DOCratosAction.Create, true)]
		[DOCratosActionColumn(DOCratosAction.Update, true)]
		public string Name
		{
			get { return (this.m_Name); }
			set { this.m_Name = value; this.NotifyPropertyChanged("Name"); this.IsChanged = true; }
		}

		/// <summary>
		/// Title Active indicator
		/// </summary>
		[DOCratosColumn("Is Active", "IsActive", DbType.Boolean, DOTitle.DBIsActiveColumn, true)]
		public bool IsActive
		{
			get { return (this.m_IsActive); }
			set { this.m_IsActive = value; this.NotifyPropertyChanged("IsActive"); this.IsChanged = true; }
		}
		#endregion

		#region Class Methods
		/// <summary>
		/// Create Object from a Serialized object
		/// </summary>
		/// <param name="objectStream">A byte array representing the serialized object</param>
		/// <returns>
		/// The recreated object
		/// </returns>
		public override IDOCratos CreateObjectFromStream(byte[] objectStream)
		{
			// Serialize the data
			return ((DOTitle)DOCratosGlobal.BinDeserialize(objectStream));
		}
		#endregion

		#region Class Support Methods
		#endregion
	}
}
